package com.qiulingcloud.sys;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.qiulingcloud.commonsserver.entity.vo.ConditionVo;
import org.assertj.core.util.Lists;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

/**
 * @Author：zhangqiang
 * @Description：
 * @Date：Created in 17:22 2020/5/2
 * @Modified By：
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SysApplication.class)
public class Others {

    /**
     * 测试Json转换
     */
    @Test
    public void jsonArrayToJsonStr() {
        List<ConditionVo> list = Lists.newArrayList();
        ConditionVo vo1 = new ConditionVo();
        vo1.setColumn("deleted");
        vo1.setType("eq");
        vo1.setValue("1");

        ConditionVo vo2 = new ConditionVo();
        vo2.setColumn("sex");
        vo2.setType("eq");
        vo2.setValue("1");
        list.add(vo1);
        list.add(vo2);

        String s = JSONArray.toJSONString(list);
        System.out.println(s);
        List<ConditionVo> conditionVos = JSON.parseArray(s, ConditionVo.class);
        System.out.println(conditionVos);
    }
}
